package scau.zxck.view;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import scau.zxck.constant.PATH;
import scau.zxck.entity.Connection;
import scau.zxck.entity.TableInfo;
import scau.zxck.utils.PathUtil;
import scau.zxck.utils.PropUtil;
import scau.zxck.utils.ViewUtil;
import scau.zxck.view.controller.ConnTreeController;
import scau.zxck.view.controller.MainController;
import java.util.ArrayList;
import java.util.List;

/**
 * 程序入口
 */

public class Main extends Application {

    public static Stage mainStage;
    public static Stage newConnStage;
    public static Stage configConnStage;
    public static Stage aboutStage;
    public static List<Connection> connectionList = new ArrayList<Connection>();
    public static List<TableInfo> tableList = new ArrayList<TableInfo>();
    public static String defaultOutDir = "";
    public static MainController mainController;
    public static ConnTreeController connTreeController;
    public static VBox connTreeMainPane;

    @Override
    public void start(Stage primaryStage) throws Exception {
        mainStage = new Stage();
        ViewUtil.initConnTreeInterface();
        primaryStage = mainStage;
        FXMLLoader mainLoader = new FXMLLoader(PathUtil.getResource(PATH.FXML_MAIN_PATH));
        Parent root = mainLoader.load();
        mainController = mainLoader.getController();
        String softwareName = PropUtil.getBasicProp("Software_Name");
        String version = PropUtil.getBasicProp("Version");
        String powered = PropUtil.getBasicProp("Powered");
        primaryStage.setTitle(softwareName + " v" + version + " - " + powered);
        primaryStage.setScene(new Scene(root, 290, 440));
        primaryStage.setResizable(false);
        primaryStage.getIcons().add((new Image("image/zxck_logo.png")));
        primaryStage.show();
    }


    public static void main(String[] args) {
        launch(args);
    }
}
